<?php require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/RHUSJW24/modconf.mex");
MYTCONN();
	$MD = 'ED';

	if (isset($_GET['RSID'])) {
		$GET = $GLOBALS['MYT']->db_array("SELECT * FROM systemoffice.staff_members WHERE smb_ID = {$_GET['RSID']}");
	} else {
		$Values = $GLOBALS['MYT']->db_array("DESCRIBE systemoffice.staff_members");
		for($a=1;$a<=$Values[0];$a++) {
			$field = $Values[$a]['Field'];
			$GET[1][$field] = '';
		}
		$GET[1]['smb_CODE'] = 0;
		$GET[1]['smb_Wage'] = 0;
		$GET[1]['smb_Dependentes'] = 0;
	}
	form_pr('staffmember','','','post');
	mn_field('hidden','ED','smb_ID',$GET[1]['smb_ID'],'','','','');
	?>
<div id="membem_menu">
	<?php
	mn_field('button',$MD,'bm_Member','Dados do Funcionario','45','45','','" style="margin:1px; height:20px; width:125px" onclick="
		document.getElementById(\'menu1\').style.display=\'block\';
		document.getElementById(\'menu5\').style.display=\'none\';document.getElementById(\'menu4\').style.display=\'none\';document.getElementById(\'menu3\').style.display=\'none\';document.getElementById(\'menu2\').style.display=\'none\';');
	mn_field('button',$MD,'bm_Company','Dados da Empresa','45','45','','" style="margin:1px; height:20px; width:125px" onclick="
		document.getElementById(\'menu2\').style.display=\'block\';
		document.getElementById(\'menu5\').style.display=\'none\';document.getElementById(\'menu4\').style.display=\'none\';document.getElementById(\'menu3\').style.display=\'none\';document.getElementById(\'menu1\').style.display=\'none\';');
	mn_field('button',$MD,'bm_Transfer','MudanÇas','45','45','','" style="margin:1px; height:20px; width:125px" onclick="
		document.getElementById(\'menu3\').style.display=\'block\';
		document.getElementById(\'menu5\').style.display=\'none\';document.getElementById(\'menu4\').style.display=\'none\';document.getElementById(\'menu1\').style.display=\'none\';document.getElementById(\'menu2\').style.display=\'none\';');
	mn_field('button',$MD,'bm_Offs','Ferias e Baixas','45','45','','" style="margin:1px; height:20px; width:125px" onclick="
		document.getElementById(\'menu4\').style.display=\'block\';
		document.getElementById(\'menu5\').style.display=\'none\';document.getElementById(\'menu1\').style.display=\'none\';document.getElementById(\'menu3\').style.display=\'none\';document.getElementById(\'menu2\').style.display=\'none\';');
	mn_field('button',$MD,'bm_Contract','Alteracoes Contractuais','45','45','','" style="margin:1px; height:20px; width:125px" onclick="
		document.getElementById(\'menu5\').style.display=\'block\';
		document.getElementById(\'menu1\').style.display=\'none\';document.getElementById(\'menu4\').style.display=\'none\';document.getElementById(\'menu3\').style.display=\'none\';document.getElementById(\'menu2\').style.display=\'none\';');
	?>
</div>
<div id="menu5" name="menu5" class="title" style="height:420px;display:none">
	<?php if ($GET[1]['smb_DesmissDate'] == '') {
		echo 'NÃo existem alteraÇ&otilde;es contractuais para este funcionário.';
	} else { ?>
	DemissÃo
<table width="100%"  border="0" cellpadding="0" cellspacing="3" bgcolor="#F2F2F2">
        <tr bgcolor="#F2F2F2">
          <td bgcolor="#F2F2F2">Iniciativa: </td>
          <td><?php mn_field('hselect',$MD,'smb_DesmissType',$GET[1]['smb_DesmissType'],'Trabalhador;Empregador#1;2','','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td bgcolor="#F2F2F2">Data de Demissao: </td>
          <td><?php mn_field('date',$MD,'smb_DesmissDate',$GET[1]['smb_DesmissDate'],'staffmember','8','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td bgcolor="#F2F2F2">Motivo: </td>
          <td><?php mn_field('text',$MD,'smb_DesmissMotive',$GET[1]['smb_DesmissMotive'],'255','40','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td bgcolor="#F2F2F2">Data de Saída da Empresa: </td>
          <td><?php mn_field('date',$MD,'smb_DesmissDateOut',$GET[1]['smb_DesmissDateOut'],'staffmember','8','',''); ?></td>
        </tr>
	</table>
	<?php } ?>
</div>
<div id="menu4" name="menu4" class="title" style="height:420px;display:none">Ferias e Baixas</div>
<div id="menu3" name="menu3" class="title" style="height:420px;display:none">MudanÇas</div>
<div id="menu2" name="menu2" class="title" style="height:420px;display:none">Dados da Empresa
<table width="100%"  border="0" cellpadding="0" cellspacing="3" bgcolor="#F2F2F2">
       <tr bgcolor="#F2F2F2">
          <td>Data de AdmissÃo: </td>
          <td NOWRAP><?php mn_field('date',$MD,'smb_AdmissionDate',$GET[1]['smb_AdmissionDate'],'staffmember','8','',''); 
		  ?></td>
        </tr>  
       <tr bgcolor="#F2F2F2">
          <td>Motivo da AdmissÃo:</td>
          <td><?php
		  mn_field('text',$MD,'smb_AdmissionMotive',$GET[1]['smb_AdmissionMotive'],'100','40','',''); ?></td>
        </tr>
       <tr bgcolor="#F2F2F2">
          <td>Tipo de Contracto:</td>
          <td><?php
		  $ct_Type = "Recibo verde; A prazo; A termo certo; Sem termo#1;2;3;4";
		  mn_field('hselect',$MD,'smb_ContractType',$GET[1]['smb_ContractType'],$ct_Type,' ','',''); ?></td>
        </tr>
       <tr bgcolor="#F2F2F2">
          <td>Numero de Funcionario:</td>
          <td><?php
		  mn_field('text',$MD,'smb_CODE',$GET[1]['smb_CODE'],'10','10','',''); ?></td>
        </tr>    
       <tr bgcolor="#F2F2F2">
          <td>Loja: </td>
          <td><?php
		  $OriDM = "SELECT OriNumero AS ID, OriNombre AS NAME FROM officeschema.origenes WHERE OriTipo = 2 AND OriNumero >= 800";
		  mn_field('select',$MD,'smb_Domain',$GET[1]['smb_Domain'],$OriDM,'','False',''); ?>
		   </td>
        </tr>   
       <tr bgcolor="#F2F2F2">
          <td>Função:</td>
          <td><?php 
		  $qr_MemberGroup = "SELECT sug_ID AS ID, sug_Name AS NAME FROM systemoffice.sys_usergroups";
		  mn_field('select',$MD,'smb_Function',$GET[1]['smb_Function'],$qr_MemberGroup,'','False',''); ?></td>
        </tr>  
       <tr bgcolor="#F2F2F2">
          <td>Salário:</td>
          <td><?php mn_field('text',$MD,'smb_Wage',$GET[1]['smb_Wage'],'8','8','','INPNUM"'); ?></td>
        </tr>
       <tr bgcolor="#F2F2F2">
          <td>Data de envio dos documentos:</td>
          <td><?php mn_field('date',$MD,'smb_DocReceived',$GET[1]['smb_DocReceived'],'staffmember','8','',''); ?></td>
        </tr>  
        <tr bgcolor="#F2F2F2">
          <td>E-mail:</td>
          <td><?php
		  mn_field('text',$MD,'smb_CttEmail',$GET[1]['smb_CttEmail'],'45','45','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td>ExtensÃo Interna:</td>
          <td><?php
		  mn_field('text',$MD,'smb_CttExtention',$GET[1]['smb_CttExtention'],'45','45','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td>Estado:</td>
          <td><?php
		  $OriST = "Activo;Suspenso;Dispensar#2;3;5";
		  mn_field('hselect',$MD,'smb_Flag',$GET[1]['smb_Flag'],$OriST,'','False',''); ?></td>
        </tr>
	</table>
</div>
<div id="menu1" name="menu1" class="title" style="height:420px;display:block">Dados do Funcionario
<table width="100%"  border="0" cellpadding="0" cellspacing="3" bgcolor="#F2F2F2">
<tr bgcolor="#F2F2F2">
          <td width="30%" valign="top">Nome:</td>
          <td width="70%"><?php
		  mn_field('text',$MD,'smb_Name',$GET[1]['smb_Name'],'45','45','',''); ?></td>
  </tr>
<tr bgcolor="#F2F2F2">
          <td width="30%" valign="top">Morada:</td>
          <td width="70%"><?php
		  mn_field('textarea',$MD,'smb_CttAddress',$GET[1]['smb_CttAddress'],'80','4','',''); ?></td>
  </tr>
<tr bgcolor="#F2F2F2">
          <td width="30%" valign="top">Contacto:</td>
          <td width="70%"><?php
		  mn_field('text',$MD,'smb_CttPhone',$GET[1]['smb_CttPhone'],'45','45','',''); ?></td>
  </tr>
<tr bgcolor="#F2F2F2">
          <td width="30%" valign="top">Documento de Identificação:</td>
          <td width="70%"><?php
          $DocTypes = "SELECT tdc_ID AS ID, tdc_Tipo AS NAME FROM officeschema.hd_documentostipos WHERE tdc_dnc = 4 AND tdc_Activo = 1 AND Country_ID = {$__sys['Country']}";
		  mn_field('select',$MD,'smb_DocID',$GET[1]['smb_DocID'],$DocTypes,' ','','');
		  echo ' Numero:';
		  mn_field('text',$MD,'smb_DocNumber',$GET[1]['smb_DocNumber'],'20','20','','');
		  echo ' Data:';
		  mn_field('date',$MD,'smb_DocDate',$GET[1]['smb_DocDate'],'staffmember','8','','');
		  echo '<br>Local: ';
		  mn_field('text',$MD,'smb_DocLocal',$GET[1]['smb_DocLocal'],'44','44','','');
		  echo ' Validade:';
		  mn_field('date',$MD,'smb_DocValid',$GET[1]['smb_DocValid'],'staffmember','8','',''); ?></td>
  </tr>
<tr bgcolor="#F2F2F2">
          <td>Contribuinte:</td>
          <td><?php
		   mn_field('text',$MD,'smb_NIF',$GET[1]['smb_NIF'],'20','20','',''); ?></td>
        </tr>
<tr bgcolor="#F2F2F2">
          <td>SeguranÇa Social:</td>
          <td><?php
		   mn_field('text',$MD,'smb_SSID',$GET[1]['smb_SSID'],'20','20','',''); ?></td>
        </tr>
		<tr bgcolor="#F2F2F2">
          <td>
		  Nacionalidade:</td>
        <td><?php
		  $qr_Country = "SELECT pai_CodElite AS ID, pai_NombreESP AS NAME FROM hd_paises";
		   mn_field('select',$MD,'smb_Nacionalidade',$GET[1]['smb_Nacionalidade'],$qr_Country,' ','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td>Data de Nascimento:</td>
          <td><?php mn_field('date',$MD,'smb_Birthdate',$GET[1]['smb_Birthdate'],'staffmember','8','',''); ?></td>
        </tr>
        <tr bgcolor="#F2F2F2">
          <td>Estado Civil:</td>
          <td><?php mn_field('hselect',$MD,'smb_Civil',$GET[1]['smb_Civil'],'Solteiro;Uniao de facto;Casado;Viuvo#1;2;3;4',' ','',''); ?></td>
        </tr>
		<tr bgcolor="#F2F2F2">
          <td>N. de Filhos:</td>
          <td><?php mn_field('text',$MD,'smb_Dependentes',$GET[1]['smb_Dependentes'],'2','2','',''); ?></td>
        </tr> 
       <tr bgcolor="#F2F2F2">
          <td>Habilitacoes literarias:</td>
          <td><?php  mn_field('textarea',$MD,'smb_Habilitacoes',$GET[1]['smb_Habilitacoes'],'80','4','',''); ?></td>
        </tr>      
    </table>
</div>
<div id="pr_user"></div>
<?php
 mn_field('button',$MD,'Save','Guardar','','','','" style="width:100%;height:20" onClick="
	document.staffmember.action=\''.$GLOBALS['URL'].'_response/rsproxy.php?pr=rh_memberchange\';
	subform(\'staffmember\',\'pr_user\');');?>
</form>